home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / WINDOWS / LZAPI.ZIP / TPW.ZIP / WLHA.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-03-15  |  7.7 KB  |  183 lines

  1. {----------------------------------------------------------------------*
  2.  *                                                                      
  3.  *    W L H A . P A S -       Dipl. Ing. Bernd Herd
  4.  *                Niederstr. 36
  5.  *                64285 Darmstadt
  6.  *                Germany
  7.  *                Tel: 06151 / 664717
  8.  *                Fax: 06151 / 664740
  9.  *    (C) 1994-95 Bernd Herd
  10.  *
  11.  * WLHA.DLL Dynamic Link Library for Microsoft Windows 3.1
  12.  * makes it possible to extract Files from and add Files to LHA-Archives
  13.  * without using LHA.EXE
  14.  *
  15.  * This is the Interface-Unit for pascal-Programs.
  16.  *
  17.   ---------------------------------------------------------------}
  18.  
  19. unit WLha;
  20.  
  21. interface
  22.  
  23. uses OWindows, WinTypes, WinProcs, Win31, WinAPI, WinDOs;
  24.  
  25.  
  26. type MFILE = THandle;                   { This is our special Kind of File I/O-Handle supported by WLHA,
  27.                                           it's basically a GlobalAlloc-Handle }
  28.  
  29. { ----------- Options ------------------------------------------------ }
  30.  
  31.   { ----------- Expand-Options --------------------------------- }
  32.   const  LHA_OVERWRITE=    $0001;        {  Codes for Options-Parameter }
  33.   const  LHA_ATTRIB=       $0010;        {  Set/Get File Attributes }
  34.  
  35.   { ----------- Append-Options --------------------------------- }
  36.   const  LHA_CREATEARCHIV=  $0100;       {  Generate a New Archiv, even if there is one already }
  37.   const  LHA_SHORTNAMES=    $0200;    {  Filenames in Archiv without Path }
  38.  
  39. { ----------- Callback Routine Messages ------------------------------ }
  40. const  LHM_PEEK=           1;             {  Nothing special }
  41. const  LHM_NEXTFILE=       2;             {  Start processing next File }
  42.  
  43. { ------------- Error Codes ------------------------------------------- }
  44. {  The Errorcode are selected to be between 2000 and 2100, so it's easier }
  45. {  to store the error text in an Resource File }
  46.  
  47. type LHERR = Integer;                             { Return Type definition }
  48.  
  49. const  LHE_OK=                       0;           {  No Error }
  50. const  LHE_ARCHIVNOTFOUND=        2020;           {  Archiv File not Found }
  51. const  LHE_BROKEN=                2021;           {  Broken Archiv }
  52. const  LHE_METHOD=                2022;           {  Compression Method not supported }
  53. const  LHE_WRITE=                 2023;           {  Error creating/writing File }
  54. const  LHE_CRC=                   2024;           {  CRC error }
  55. const  LHE_CALLBACK=              2025;           {  Callbackroutine returned LHAN_STOP }
  56. const  LHE_INSTANCE=              2026;           {  Instanz-Handling-Fehler }
  57. const  LHE_INFILENOTFOUND=        2027;           {  Input File not found }
  58. const  LHE_STOPPED=               2028;           {  Stopped by Callbac-Routine }
  59.  
  60. { ------------- Callback-Notification-Codes ----- }
  61. const  LHN_OK=                    0;              {  Nothing special }
  62. { #define LHN_IGNOREFILE                 1              // Used with LHAM_NEXTFILE : Irgnore this File }
  63. const  LHN_STOP=                  2;              {  Used with LHAM_PEEK     : Stop Decompression of Archive immediatly }
  64.  
  65.  
  66. type datetimerecord = record
  67.         time : Word;
  68.         date : Word;
  69.         End;
  70.  
  71.      LPLHHEAD = ^LHHEAD;
  72.      LHHEAD = record
  73.     headersize  : Integer;
  74.         method      : array[0..5] of char;
  75.         PackedSize  : LongInt;                    { Packed FIle Size }
  76.         Skip        : LongInt;
  77.         OriginalSize: LongInt;                    { Original File Size }
  78.  
  79.         dostime     : DateTimeRecord;             { Parameter like GetFTime }
  80.  
  81.     utc         : LongInt;                    { Another Time Format... }
  82.         attr        : Integer;                    { File Attribute (Archiv,System,Hidden...) }
  83.         level       : Integer;                    { Header Level }
  84.  
  85.         filecrc     : Word;                       { File CRC }
  86.         headcrc     : Word;                       { Header CRC (Method depends on level) }
  87.  
  88.         dos         : Integer;
  89.  
  90.         pathname    : PChar;
  91.         filename    : PChar;                      { Filename, when extracting! }
  92.  
  93.         dirnlen     : Integer;                    { Directory name Length }
  94.         filenlen    : Integer;                    { File Name Length }
  95.  
  96.         info        : Integer;
  97.         currentpos  : LongInt;                    { Position of currently used Header in the File }
  98.  
  99.         crcpos      : PChar;
  100.         End;
  101.  
  102.  
  103.  
  104. { Typedefintion for Callback cannot be adopted to Pascal :-( }
  105.  
  106. { typedef LHERR (CALLBACK* LHCALLBACK)(int, LPLHHEAD);      Type declaration Callback-Function }
  107. type LHCALLBACK = Pointer;
  108.  
  109.  
  110. { ----------- High-Level-Routines ----------------------------- }
  111.  
  112. function LHExpand( ArchivName : PChar;          {  Extract Files from Archiv }
  113.            PathName   : PChar;
  114.            Wildcards  : PChar;        {  Wildcards (i.e. "*.TXT") or NULL }
  115.            Options    : Integer ) : LHERR; far;
  116.  
  117. function LHAppend( ArchivName : PChar;          {  Append File or Create Archiv }
  118.            PathName   : PChar;
  119.            Options    : Integer ) : LHERR; far;
  120.  
  121.  
  122. function LHInit(   Instance   : THandle) : LHERR; far; {  Initialize for next Archiv Operation(s) }
  123. function LHEnd (   Instance   : THandle) : LHERR; far; {  End of Archiv Operation(s) }
  124.  
  125. procedure LHMessage( eId : LHERR ); far;        {  Show Error Message Box }
  126.  
  127. function LHSetCallback(   TheCallback : LHCALLBACK) : LHERR; far; {  Set Callback-Routine }
  128. function LHDefCallbck( msg : Integer; p : LPLHHEAD) : LHERR; far; {  Default-Callback-Routine }
  129.  
  130. procedure LHErrMsgBox( eId : LHERR ); far;        {  Show Error Message Box with Description }
  131.  
  132.  
  133. { ----------- Medium-Level-Routines --------------------------- }
  134.  
  135. function LHAppendNext(  marc : MFILE;                {  File Handle Archiv }
  136.             minp : MFILE;                {  File Handle Input File }
  137.             FileName : PChar;            {  FileName Inside Archiv }
  138.             Options  : Integer): LHERR; far; {  Archiving Options }
  139.  
  140.  
  141. function LHExpandNext(  marc    : MFILE;                 {  File Handle of input-Archiv }
  142.                         Wildcards  : PChar;        {  Wildcards (i.e. "*.TXT") or NULL }
  143.             Options : Integer) : LHERR; far; {  Decompression Options }
  144.  
  145.  
  146.  
  147. implementation
  148.  
  149. function LHExpand( ArchivName : PChar;          {  Extract Files from Archiv }
  150.            PathName   : PChar;
  151.            Wildcards  : PChar;        {  Wildcards (i.e. "*.TXT") or NULL }
  152.            Options    : Integer ) : LHERR; external 'WLHA';
  153.  
  154. function LHAppend( ArchivName : PChar;          {  Append File or Create Archiv }
  155.            PathName   : PChar;
  156.            Options    : Integer ) : LHERR; external 'WLHA';
  157.  
  158.  
  159. function LHInit(   Instance   : THandle) : LHERR; external 'WLHA'; {  Initialize for next Archiv Operation(s) }
  160. function LHEnd (   Instance   : THandle) : LHERR; external 'WLHA'; {  End of Archiv Operation(s) }
  161.  
  162. procedure LHMessage( eId : LHERR ); external 'WLHA';        {  Show Error Message Box }
  163.  
  164. function LHSetCallback(   TheCallback : LHCALLBACK) : LHERR; external 'WLHA'; {  Set Callback-Routine }
  165. function LHDefCallbck( msg : Integer; p : LPLHHEAD) : LHERR; external 'WLHA'; {  Default-Callback-Routine }
  166.  
  167. procedure LHErrMsgBox( eId : LHERR ); external 'WLHA';        {  Show Error Message Box with Description }
  168.  
  169.  
  170. { ----------- Medium-Level-Routines --------------------------- }
  171.  
  172. function LHAppendNext(  marc : MFILE;                {  File Handle Archiv }
  173.                         minp : MFILE;                {  File Handle Input File }
  174.                         FileName : PChar;            {  FileName Inside Archiv }
  175.                         Options  : Integer): LHERR; external 'WLHA'; {  Archiving Options }
  176.  
  177.  
  178. function LHExpandNext(  marc     : MFILE;               {  File Handle of input-Archiv }
  179.             Wildcards: PChar;        {  Wildcards (i.e. "*.TXT") or NULL }
  180.             Options  : Integer) : LHERR; external 'WLHA'; {  Decompression Options }
  181.  
  182. End.
  183.